package configuration.dataObjects
{
	import mx.collections.ArrayCollection;
	import common.utils.DateManager;
	
	public class ConfigValueDO
	{
		public var OBJECT_ID:Number = 0;
		public var RECORD_TYPE:String = "";
		public var IDENTIFIER:String = "";
		public var VALUE:String = "";
		public var DESCRIPTION:String = "";
		
		public function ConfigValueDO()
		{
			
		}
		
		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}			
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
			<CONFIG_VALUE>
				<OBJECT_ID>{OBJECT_ID}</OBJECT_ID>
				<RECORD_TYPE>{RECORD_TYPE}</RECORD_TYPE>
				<IDENTIFIER>{IDENTIFIER}</IDENTIFIER>
				<VALUE>{VALUE}</VALUE>
				<DESCRIPTION>{DESCRIPTION}</DESCRIPTION>			
			</CONFIG_VALUE>;
			return xmlObj;
		}

		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var wavDO:ConfigValueDO = new ConfigValueDO();
				wavDO.Init(xml);
				ac.addItem(wavDO);
			}
			return ac;
		}
	}
}